#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Ocelot.Admin.Api/Ocelot.Admin.Api.Web.Entry/Ocelot.Admin.Api.Web.Entry.csproj", "Ocelot.Admin.Api/Ocelot.Admin.Api.Web.Entry/"]
COPY ["Ocelot.Admin.Api/Ocelot.Admin.Api.Web.Core/Ocelot.Admin.Api.Web.Core.csproj", "Ocelot.Admin.Api/Ocelot.Admin.Api.Web.Core/"]
COPY ["Ocelot.Admin.Api/Ocelot.Admin.Api.Application/Ocelot.Admin.Api.Application.csproj", "Ocelot.Admin.Api/Ocelot.Admin.Api.Application/"]
COPY ["Ocelot.Admin.Api/Ocelot.Admin.Api.Core/Ocelot.Admin.Api.Core.csproj", "Ocelot.Admin.Api/Ocelot.Admin.Api.Core/"]
RUN dotnet restore "Ocelot.Admin.Api/Ocelot.Admin.Api.Web.Entry/Ocelot.Admin.Api.Web.Entry.csproj"
COPY . .
WORKDIR "/src/Ocelot.Admin.Api/Ocelot.Admin.Api.Web.Entry"
RUN dotnet build "Ocelot.Admin.Api.Web.Entry.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Ocelot.Admin.Api.Web.Entry.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Ocelot.Admin.Api.Web.Entry.dll"]